﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using ASPItalia.ModelVirtualCasting.Common;
using ASPItalia.ModelVirtualCasting.ObjectModel;

namespace ASPItalia.ModelVirtualCasting.Fake
{
    public class ModelRepository : BaseRepository<IModelRepository>, IModelRepository
    {
        private List<Model> list = new List<Model>();

        public ModelRepository()
        {
            Model model = new Model();
            model.NickName = "Patricia";
            model.BirthDate = new DateTime(1985, 1, 1);
            model.NationalityCountry = new Country { CountryName = "U.S.A." };
            list.Add(model);

            model = new Model();
            model.NickName = "Carla";
            model.BirthDate = new DateTime(1984, 1, 1);
            model.NationalityCountry = new Country { CountryName = "Italia" };
            list.Add(model);

            model = new Model();
            model.NickName = "Monika";
            model.BirthDate = new DateTime(1982, 1, 1);
            model.NationalityCountry = new Country { CountryName = "Russia" };
            list.Add(model);

            model = new Model();
            model.NickName = "Claire";
            model.BirthDate = new DateTime(1988, 1, 1);
            model.NationalityCountry = new Country { CountryName = "Francia" };
            list.Add(model);
        }

        public void InsertOnSubmit(Model entity)
        {
        }

        public void Update(Model entity)
        {
        }

        public void DeleteOnSubmit(Model entity)
        {
        }

        public void SubmitChanges()
        {
        }

        public IQueryable<ModelDTO> GetRandomModels(int number)
        {
            string imageUrl = "default.png";

            var res = from m in this.list
                      select new ModelDTO()
                      {
                          Age = DateTime.Today.Year - m.BirthDate.Year,
                          Country = m.NationalityCountry.CountryName,
                          ImageUrl = imageUrl,
                          NickName = m.NickName
                      };

            return res.AsQueryable();
        }

        public IQueryable<Model> GetAll()
        {
            return null;
        }

        public IQueryable<Model> Where(Expression<Func<Model, bool>> predicate)
        {
            return null;
        }

        public long Count(Expression<Func<Model, bool>> predicate)
        {
            return 0L;
        }

				#region IReadOnlyRepository<IModelRepository,Model> Members


				public IModelRepository EnableLazyLoading()
				{
					throw new NotImplementedException();
				}

				public IModelRepository DisableLazyLoading()
				{
					throw new NotImplementedException();
				}

				public IModelRepository Include(string path) {
					return this;
				}
				#endregion
		}
}
